<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<ui:composition template="../template.xhtml">
	<ui:define name="content">
		<rich:panel>
		<f:facet name="header">
			<h:outputText value="#{slotStockItemEditorBean.title}" />
		</f:facet>
		<h:form>
			<h:messages />
		   	<h:panelGrid columns="3">
		    	<h:outputText value="Slot" />
		    	<rich:select id="slotSelect" value="#{slotStockItemEditorBean.slot}" converter="#{slotConverter}" required="true" requiredMessage="Slot is required">
		    		<f:selectItems value="#{slotStockItemEditorBean.slots}" var="slot" itemLabel="#{slot.name} (Remaining: #{slot.capacity - slot.usedCapacity})" itemValue="#{slot}" itemValueAsString="#{slot.id}" />
		    	</rich:select>
		    	<rich:message for="slotSelect" />
		    	<h:outputText value="Placing date:" />
		    		<rich:calendar value="#{slotStockItemEditorBean.placingDate}" id="placingDate" locale="#{slotStockItemEditorBean.calendarLocale}" datePattern="#{slotStockItemEditorBean.calendarPattern}" cellWidth="24px" cellHeight="22px" style="width:200px" required="true" requiredMessage="Placing date is required." />
		    	<rich:message for="placingDate" />
		    	<h:outputText value="Amount:" />
					<h:inputText id="amount" required="true" value="#{slotStockItemEditorBean.ammount}"
								 requiredMessage="Amount is required" label="Amount">
						<f:validateLongRange minimum="1" />
					</h:inputText> Kg
					<rich:message for="amount" />
		    </h:panelGrid>
		     <!-- Ovladacie tlacitka -->
		     <a4j:commandButton value="Save" action="#{slotStockItemEditorBean.submit}" />
		     <a4j:commandButton value="Cancel" immediate="true" action="#{slotStockItemEditorBean.cancel}" />
	     </h:form>
	 	</rich:panel>
	</ui:define>
</ui:composition>
</html>